//StringBuilder和String的相互转换
package text;

public class StudentDemo {
    public static void main(String[] args) {

        //StringBuilder 转换成 String
        StringBuilder sb = new StringBuilder();
        sb.append("hello");

//        String s = sb;//这是个错误的做法

//        public String toString():通过toString()就可以把StringBuilder转换成String
        String s = sb.toString();
        System.out.println(s);

        //String 转换成 StringBuilder
        String s1 ="world";

//         public StringBuilder(String s):通过构造方法就可以实现把String转换成StringBuilder
        StringBuilder sb1 = new StringBuilder(s1);
        System.out.println(sb1);

    }
}
